﻿using UnityEngine;

namespace ZFramework.Runtime
{
    public delegate void LoadAssetSuccessCallback(string assetName, Object asset, float duration, object userData);

    public delegate void LoadAssetFailureCallback(string assetName, string errorMessage, object userData);

    public class LoadAssetCallbacks
    {
        private readonly LoadAssetSuccessCallback _loadAssetSuccessCallback;
        private readonly LoadAssetFailureCallback _loadAssetFailureCallback;

        public LoadAssetCallbacks(LoadAssetSuccessCallback loadAssetSuccessCallback)
            : this(loadAssetSuccessCallback, null)
        {
        }

        public LoadAssetCallbacks(LoadAssetSuccessCallback loadAssetSuccessCallback,
            LoadAssetFailureCallback loadAssetFailureCallback)
        {
            _loadAssetSuccessCallback = loadAssetSuccessCallback;
            _loadAssetFailureCallback = loadAssetFailureCallback;
        }

        public LoadAssetSuccessCallback LoadAssetSuccessCallback
        {
            get { return _loadAssetSuccessCallback; }
        }

        /// <summary>
        /// 获取加载资源失败回调函数。
        /// </summary>
        public LoadAssetFailureCallback LoadAssetFailureCallback
        {
            get { return _loadAssetFailureCallback; }
        }
    }
}
